linux下如何在vscode中配置opencv环境 | 您所在的位置:网站首页 › vs code配置c环境 › linux下如何在vscode中配置opencv环境 |
这里使用的是C++作为编程语言,当然默认读者已经配置好了C++的编程环境 首先使用 pkg-config --modversion opencv命令查看版本,确保成功安装了o p e n c v opencv o p e n c v,我的版本是 4.5.4 #include #include int main(){ cv::Mat image = cv::imread("tiger.jpg"); cv::namedWindow("My Image"); cv::imshow("My Image", image); cv::waitKey(5000); return 1; }如果现在新建一个 cpp文件,输入上面的内容(这个tiger.jpg应该是当前目录下的一张图片)看到的应该是下面的画面 ![]() 这时候,我们打开 c_cpp_properties.json文件,在 includePath中加入一行 "/usr/local/include/**",改成下面这样 { "configurations": [ { "name": "Linux", "includePath": [ "${workspaceFolder}/**", "/usr/local/include/**" ], "defines": [], "compilerPath": "/usr/bin/cpp", "cStandard": "gnu17", "cppStandard": "c++17", "intelliSenseMode": "linux-gcc-x64" } ], "version": 4 }就在那时,我们发现红色的波浪线消失了。 [En]That’s when we found that the red wavy line had disappeared. ![]() ![]() 这个文件变成了下面这样 { "version": "2.0.0", "tasks": [ { "label": "build", "type": "shell", "command": "g++", "args": [ "-g", "${file}", "-std=c++11", "-o", "${fileBasenameNoExtension}.out", "-I", "/usr/local/include", "-I", "/usr/local/include/opencv4", "-L", "/usr/local/lib", "-l", "opencv_core", "-l", "opencv_imgproc", "-l", "opencv_imgcodecs", "-l", "opencv_video", "-l", "opencv_ml", "-l", "opencv_highgui", "-l", "opencv_objdetect", "-l", "opencv_flann", "-l", "opencv_imgcodecs", "-l", "opencv_photo", "-l", "opencv_videoio" ] }, { "type": "cppbuild", "label": "C/C++: cpp 生成活动文件", "command": "/usr/bin/cpp", "args": [ "-fdiagnostics-color=always", "-g", "${file}", "-o", "${fileDirname}/${fileBasenameNoExtension}" ], "options": { "cwd": "${fileDirname}" }, "problemMatcher": [ "$gcc" ], "group": "build", "detail": "编译器: /usr/bin/cpp" } ] }然后返回并再次运行,但仍报告错误。 [En]Then come back and run it again, and still report an error. ![]() And then we run the program again and it’s a success, probably like this, this is a picture of my local. ![]() Original: https://blog.csdn.net/roadtohacker/article/details/121201073Author: Coming LiuTitle: linux下如何在vscode中配置opencv环境 原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/257458/ 转载文章受原作者版权保护。转载请注明原作者出处! |
今日新闻 |
推荐新闻 |
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 |